1dd6de401c083d22df35dc0ed23752f9d6957061
5 from datetime
import date
, datetime
, timedelta
13 conn
= sqlite3
.connect(DATABASE
)
16 for vote
in c
.execute('select id, id_group, date_end, title from votes where is_open=1 and is_terminated=0'):
17 date_end_vote
= datetime
.strptime(vote
[2], "%Y-%m-%d")
18 date_today
= datetime
.today()
19 date_begin_reminder
= date_end_vote
+ timedelta(days
=-3)
21 if date_today
>= date_begin_reminder
and date_today
<= date_end_vote
:
22 voting_group
= (vote
[1],)
23 for user
in c
.execute('select users.id, users.email, users.name from users join user_group on users.id=user_group.id_user where user_group.id_group = ?', voting_group
).fetchall():
24 userchoice_request
= (user
[0], vote
[0],)
25 userchoice
= c
.execute('select * from user_choice join choices on user_choice.id_choice = choices.id where id_user = ? and id_vote = ?', userchoice_request
).fetchone()
26 print "Checking if user %s already voted %s" % (user
[1], vote
[3])
28 if userchoice
is None:
30 link
= "http://vote.ffdn.org/vote/%d" % vote
[0]
34 "Subject: [Cavote] Vote reminder - You didn't take part to it",
35 "Date: %s" % time
.strftime("%a, %d %b %Y %H:%M:%S +0000", time
.gmtime()).decode('utf-8'),
36 "X-Mailer: %s" % VERSION
,
38 "A vote concerns you and is going to terminate on %s : %s" % (vote
[2], vote
[3]),
39 "You still didn't take part to it !",
41 "This link will bring you to the form where you will be able to participate :",
44 "If you think this mail is not for you, please ignore and delete it."
46 server
= smtplib
.SMTP(SMTP_SERVER
)
50 server
.sendmail(EMAIL
, user
[1], BODY
)
56 "Subject: [Cavote] Vote reminder - Last days to modify your choice",
57 "Date: %s" % time
.strftime("%a, %d %b %Y %H:%M:%S +0000", time
.gmtime()).decode('utf-8'),
58 "X-Mailer: %s" % VERSION
,
60 "A vote concerns you and is going to terminate on %s : %s" % (vote
[2], vote
[3]),
61 "You have already voted by can still modify you choice",
63 "This link will bring you to the form where you will be able to participate :",
66 "If you think this mail is not for you, please ignore and delete it."
68 server
= smtplib
.SMTP(SMTP_SERVER
)
72 server
.sendmail(EMAIL
, user
[1], BODY
)